/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * logRacas.java
 *
 * Created on 20/01/2010, 19:49:18
 */

package cparc;

import com.mysql.jdbc.Statement;
import java.sql.ResultSet;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Administrador
 */
public class logRacas extends javax.swing.JInternalFrame {

    /** Creates new form logRacas */
    public logRacas() {
        initComponents();

        DefaultTableModel modelo = (DefaultTableModel) tbLog.getModel();
        Statement stm = null;
        String result = null;
        String consulta = "SELECT DATA_LOG,USUARIO,ACAO FROM CPARC.LOG_SIMP ORDER BY DATA_LOG DESC";
        int i=0;

        try  {
        stm = (Statement) conexao.getConnection(true).createStatement();
        ResultSet rs = stm.executeQuery(consulta);

        while(rs.next()){
        modelo.addRow(new String[] {rs.getString("DATA_LOG"), rs.getString("USUARIO"),rs.getString("ACAO")});
        modelo.fireTableCellUpdated(i, 0);
        modelo.fireTableCellUpdated(i, 1);
        modelo.fireTableCellUpdated(i, 2);
        i++;
        }

        }
        catch(Exception e){
            String status = e.getMessage();
            System.out.println(status);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        tbLog = new javax.swing.JTable();

        setClosable(true);
        setTitle("Log de Raças");

        tbLog.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Data", "Usuário", "Mensagem"
            }
        ));
        jScrollPane1.setViewportView(tbLog);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(18, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 955, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(21, Short.MAX_VALUE))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-993)/2, (screenSize.height-311)/2, 993, 311);
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable tbLog;
    // End of variables declaration//GEN-END:variables

}
